#ifndef NODE_HPP
#define NODE_HPP

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <list>
#include <queue>

#include <SmegTools/Config.h>
#include <SmegTools/Debug/DebugNew.hpp>

namespace smeg {
    namespace ai {

////////////////////////////////////////////////////////////
/// Represents a Node in the grid
////////////////////////////////////////////////////////////
struct Node
{
    typedef std::list< Node >             td_NodeList;
    typedef std::list< Node >::iterator   td_NodeListIt;

    ////////////////////////////////////////////////////////////
    /// Default Constructor
    ///
    /// \param _iX : X position in the grid
    /// \param _iX : Y position in the grid
    ///
    ////////////////////////////////////////////////////////////
                    Node( int _iX = 0, int _iY = 0 );
    ////////////////////////////////////////////////////////////
    /// Copy Constructor
    ///
    /// \param _Copy : Node to copy
    ///
    ////////////////////////////////////////////////////////////
                    Node( const Node& _Copy );

    ////////////////////////////////////////////////////////////
    /// Setup a Node
    ///
    /// \param _iX : X position in the grid
    /// \param _iX : Y position in the grid
    ///
    ////////////////////////////////////////////////////////////
    void            Setup( int _iX, int _iY );
    
    ////////////////////////////////////////////////////////////
    /// Compute the distance to another node
    ///
    /// \param _Other : Other node to compute the distance with
    ///
    /// \return The distance to the other node
    ///
    ////////////////////////////////////////////////////////////
    float           DistanceTo( const Node& _Other ) const;
    ////////////////////////////////////////////////////////////
    /// Compute the squared distance to another node
    ///
    /// \param _Other : Other node to compute the squared distance with
    ///
    /// \return The squared distance to the other node
    ///
    ////////////////////////////////////////////////////////////
    float           SquaredDistanceTo( const Node& _Other ) const;

    /*********************** Operators ************************/
    bool            operator==( const Node& _Other ) const;
    bool            operator!=( const Node& _Other ) const;
    bool            operator>( const Node& _Other ) const;
    bool            operator>=( const Node& _Other ) const;
    bool            operator<( const Node& _Other ) const;
    bool            operator<=( const Node& _Other ) const;

    /********************* Static members *********************/
    static int      UniqueKey( Node* _pNode, int _iOffset );

    /********************* Public members *********************/
    int             X;
    int             Y;

    float           F;
    float           G;

    Node*           parent;
};

    } // namespace ai
} // namespace smeg

#include <SmegTools/Debug/DebugNewOff.hpp>

#endif // NODE_HPP